<?php
/**
 * Created by PhpStorm.
 * Author: QinShuai
 * Email: qinshuai0423@qq.com
 * Date: 2021/6/28
 */

namespace backend\controllers;

use backend\models\AdminUser;
use backend\traits\Controller;

class AdminLogController extends BaseController
{
    use Controller;

    public function filter(&$map)
    {
        $params = \Yii::$app->request->get();
        $map['_order'] = 'l.id';
        $map['_field'] = ['l.*','u.username'];

        $map['_func'] = function ($model) use (&$map) {
            $model->alias('l')->leftJoin(AdminUser::tableName().' u','u.id=l.uid');

        };
        if(isset($params['username']) && $params['username']){
            $map['u.username'] = $params['username'];
        }
    }
    public function afterFilter(&$data)
    {
        foreach ($data as &$val){
            $val['create_at'] = date('Y-m-d',$val['create_at']);
        }
    }
}